//
//  ZH_MineAccoutViewController.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/23.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineAccoutViewController.h"
#import "ZH_MineAccountTableViewCell.h"
#import "ZH_MineBankCardViewController.h"
#import "ZH_MinePayViewController.h"
@interface ZH_MineAccoutViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,weak)UITableView *tableView;
@property (nonatomic,weak)UIImageView *bottomImage;
@property (nonatomic,weak)UILabel *bottomLabel;

@end

@implementation ZH_MineAccoutViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUserInterface];
}
- (void)initUserInterface{
    self.navigationItem.title = @"我的账户";
    self.view.backgroundColor = kCommonBackgroudColor;
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(FITSCALE(112));
    }];
    [self.bottomImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tableView.mas_bottom).offset(FITSCALE(30));
        make.left.equalTo(self.view).offset(FITSCALE(85));
    }];
    [self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bottomImage);
        make.left.equalTo(self.bottomImage.mas_right).offset(FITSCALE(4));
    }];
}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
        ZH_MineAccountTableViewCell *cell = [ZH_MineAccountTableViewCell cellWithTableView:tableView];
        cell.leftString = @"支付宝";
        return cell;
    }
    else if (indexPath.row == 0){
        ZH_MineAccountTableViewCell *cell = [ZH_MineAccountTableViewCell cellWithTableView:tableView];
        cell.leftString = @"银行卡";
        return cell;
    }
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        ZH_MineBankCardViewController *vc = [[ZH_MineBankCardViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }
    else if (indexPath.row == 1){
        ZH_MinePayViewController *vc = [[ZH_MinePayViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }
}
#pragma mark - getter,setter
- (UITableView *)tableView{
    if(!_tableView){
        UITableView *tableView = [UITableView createTableViewWithDelegateTarget:self];
        tableView.backgroundColor = [UIColor clearColor];
        tableView.scrollEnabled = NO;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [tableView setCellAutoAdaptationForEstimatedRowHeight:FITSCALE(100)];
        [self.view addSubview:_tableView = tableView];
    }
    return _tableView;
}
- (UIImageView *)bottomImage{
    if (!_bottomImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_ts"];
        [self.view addSubview:_bottomImage = image];
    }
    return _bottomImage;
}
- (UILabel *)bottomLabel{
    if (!_bottomLabel) {
        UILabel *label = [UILabel createLabelWithText:@"提交后不可再修改, 请认真如实填写" font:kFontSize_24];
        label.textColor = [UIColor colorWithHexString:@"#999999"];
        [self.view addSubview:_bottomLabel = label];
    }
    return _bottomLabel;
}
@end
